<style type="text/css">
    
.layui-form-label.layui-required:after{
        content:"*";
        color:red;
       
    }

</style>
<div class="layui-fluid">
    <div class="layui-form" id="layuiadmin-form-useradmin" lay-filter="layuiadmin-form-useradmin" style="padding: 20px 0 0 0;">
        <div class="layui-form-item">
            <label class="layui-form-label layui-required">
                用户名
            </label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input  layui-btn-disabled" lay-verify="required"  placeholder="请输入用户名" type="text" value="{$data.username}" readonly="true">
                </input>
            </div>
        </div>  


        <div class="layui-form-item">
            <label class="layui-form-label">
                密码
            </label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" lay-verify="password"  name="password"  type="text" value=""   placeholder="不修改请留空" lay-min="6" lay-max="20">
                </input>
            
            </div>
        </div>  


        <div class="layui-form-item">
            <label class="layui-form-label">
                真实姓名
            </label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input"   name="truename" placeholder="请输入真实姓名" type="text" value="{$data.profile.truename}" >
                </input>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                手机号码
            </label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input"   name="phone" placeholder="请输入号码" type="text" value="{$data.phone}">
                </input>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-required">
                邮箱
            </label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" lay-verify="email" name="email" placeholder="请输入邮箱" type="text" value="{$data.email}">
                </input>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                头像
            </label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input"  name="avatar" placeholder="请上传图片" type="text" value="{$data.profile.avatar}">
                </input>
            </div>
            <button class="layui-btn" id="layuiadmin-upload-useradmin" style="float: left;" type="button">
                上传图片
            </button>
        </div>
        <div class="layui-form-item" lay-filter="sex">
            <label class="layui-form-label">
                选择性别
            </label>
            <div class="layui-input-block">
                 {$data.sex|output_checkbox='sex',[1=>'男',2=>'女'],###|raw}
            </div>
        </div>
         <div class="layui-form-item" lay-filter="sex">
            <label class="layui-form-label layui-required">
                角色
            </label>
            <div class="layui-input-block">
                 {$data.role|output_checkbox_mult='roles',$roles,###|raw}
            </div>
        </div>

        <div class="layui-form-item" lay-filter="status">
            <label class="layui-form-label">
                冻结
            </label>
            <div class="layui-input-block">
                 {$data.status|output_checkbox='status',[0=>'禁用',1=>'启用'],###|raw}
            </div>
        </div>
        
        <div class="layui-form-item layui-hide">
            <input type="hidden" name="u_id" value="{$data.u_id}" />
            <input id="LAY-user-front-submit" lay-filter="LAY-user-front-submit" lay-submit="" type="button" value="确认">
            </input>
        </div>
    </div>
</div>
<script>
    layui.use(['index', 'form', 'upload'], function(){
    var $ = layui.$
    ,form = layui.form
    ,upload = layui.upload 
    , e = layui.layer;

    form.verify({
        password: function(value, item){
            if(!value) return ;
            var min = item.getAttribute('lay-min');
            var max = item.getAttribute('lay-max');
            if(value.length < min){
                return '密码不能小于'+min+'个字符';
            } 

            if(value.length >max){
                return '密码不能超过'+max+'个字符';
            }
        }
    });
    
    upload.render({
      elem: '#layuiadmin-upload-useradmin'
      ,url: layui.setter.app_url + 'common/upload'
      ,accept: 'images'
      ,method: 'get'
      ,acceptMime: 'image/*'
      ,done: function(res){
        $(this.item).prev("div").children("input").val(res.data.src[0])
      }
    });
 
  })
</script>
